home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 1 / BBS in a box - Trilogy I.iso / Files / Publish / H-I / Hints Folder / HyperCard Hints next >
Encoding:
Text File  |  1990-11-20  |  11.0 KB  |  237 lines  |  [TEXT/MSWD]

  1. Targets and The Targets
  2. In HyperCard 1.2, “target” refers to a field’s contents. In 1.1 it refers to a card, button or field. In 1.2 you refer to a card, button or field as “the target”. Get it?
  3.  
  4. Compacting Trick
  5. When you load a stack created pre-1.2, compact it two times in 1.2 for best results.
  6.  
  7. Undos and Reverts
  8. If you accidentally erase all of a card’s graphics (double clicking the eraser does this), immediately press the tilde (~) or Escape key, or Command/Z. If that fails, try Revert from the Paint menu. Revert takes you back to when you last entered this card, so watch out.
  9.  
  10. Initializing Variable
  11. To initialize a variable, put the assignment of the variable into an openStack script. Here is an example:
  12.  
  13. on openStack
  14.     global var
  15.     if var is empty then put 12 into var
  16. end openStack
  17.  
  18. This means that no matter how often you go to this stack, the var will only be assigned this value the first time, since the second time into the stack the variable will no longer be empty.
  19.  
  20. Double Click to the Message Box
  21. You don’t have to mouse to a Message Box that is already open. Command/M two times closes the box and then reopens it with the cursor blinking inside.
  22. And when you are in the message box, the cursor can be anywhere, not just at the end of the typing, to execute the command.
  23.  
  24. Easy Formatting
  25. Double clicking on the A in the Tools menu (it has to be “torn off” first) brings up the font formatting dialog. You can also go to the formatting dialog during typing, or at any time before you click the mouse elsewhere on the card.
  26.  
  27. Using Plain English
  28. Did you know that “Not” in HyperTalk is like not in English? For example:
  29.  
  30. if the variable is not "Yes" then do whatever you want to do
  31. or
  32. on mouseUp
  33.     set visible of field "fieldname" to not visible of field "fieldname"
  34. end mouseUp
  35. Finding Misspelled Words
  36. If you spell something wrong in a script, you can find all other occurrences of the error this way:
  37.  
  38. searchscript "misspelled word", "stackname" 
  39.  
  40. where misspelled word is the error and stackname  is the stack to be searched.
  41.  
  42. Duplicating a Background
  43. Here's a way to re-use a background as a second distinct background in a stack: Copy the card, go to a temporary stack, Paste the card. Copy this card immediately. Go to the original stack and Paste the card. Now you have two identical backgrounds in the stack, not just two cards operating under the same background. You'll probably think of a use for this if you try hard enough.
  44.  
  45. How Much Space Left?
  46. Type the diskspace into the message box, hit Return, and you get the remaining space on the current drive.
  47.  
  48. Select and Print
  49. You can print just a part of a script when you are in the script editor. Just highlight the part you want to print and click on Print.
  50.  
  51. Using the Selection Tool
  52. Command/S shrinks around a selection until there is no surrounding space. If you want a rectangular selection, but no extra space, hold down the Command key while selecting the Selection tool.
  53.  
  54. For Big Screen Users
  55. This handy script is for Mac II and other big screen users. It sets up HyperCard with the message box, tool palette and pattern palette all open. Put these two scripts in place:
  56. First, under StartUp in the Home stack script, type a line,
  57.  
  58. setWindow. 
  59.  
  60. Second, type this script at the end of your Home stack script:
  61.  
  62. on setWindow
  63.     answer "Which CPU?" with "Mac II" or "Mac+"
  64.     if it is "Mac II" then
  65.         show menuBar
  66.         show card window at 20,50
  67.         show tool window at 524,198
  68.         show pattern window at 524,36
  69.         show message window at 0,370
  70.     else if it is "Mac+" then
  71.         show card window at 0,0
  72.         hide tool window
  73.         hide pattern window
  74.         show msg at 30,260
  75.         hide msg
  76.     end if
  77. end setWindow
  78.  
  79. You can change the x,y of the various windoids and windows if you like.
  80.  
  81. Button, Button; Who Has the Button
  82. If you have trouble losing buttons, put this script in your Home Stack script and you'll be warned before deleting a button:
  83.  
  84. on deleteButton
  85.     answer "You are about to delete this button."¬
  86.     with "OK" or "Don't do that!"
  87.     if it is "Don't do that!" then
  88.         doMenu "copy button"
  89.         doMenu "paste button"
  90.     end if
  91. end deleteButton
  92.  
  93. Locked fields can act like a button. Once the field is locked, you can place a mouseUp handler into the script of the field so it will do its button thing.
  94.  
  95. Sorting Fields
  96. Here's a handy field sorter. Let's say you type in a list of names in a field. You want to sort them. Assuming that it is a list of last names only, you can sort them. Or you can sort lines based on the beginning sequence of characters. Here is the script to do it:
  97.  
  98. on mouseUp
  99.   set lockscreen to true -- unless you want to watch it sort
  100.   set cursor to 4 -- the wristwatch
  101.   put number of words of field 1 into N -- or number of lines
  102.   -- replace field 1 with number of field
  103.   put 1 into m
  104.   repeat while m<N
  105.     put 3*m+1 into m
  106.   end repeat
  107.   repeat while m>1
  108.     put m div 3 into m
  109.     repeat with j=m+1 to N
  110.       get word j of field 1
  111.       put (j-m) into i
  112.       repeat until i<=0
  113.             if it >= word i of field 1 then exit repeat
  114.             put word i of field 1 into word (i+m) of¬ field 1
  115.             subtract m from i
  116.           end repeat
  117.           put it into word (i+m) of field 1
  118.     end repeat
  119.   end repeat
  120.   set lockscreen to false -- unless you want to watch it sort
  121.   set cursor to 5 -- arrow or browse tool
  122. end mouseUp
  123.  
  124. The credit for this script goes to Shell, but no first name was given. It appeared in Wheels For The Mind, Vol. 4, No. 2.
  125.  
  126. Little Lost Button
  127. Didja ever hide a button or field on yourself? Not to worry. This script by Paul Foraker will find it for you. And all the rest of your hidden buttons or fields, too.
  128.  
  129. -- make a new (temporary) button
  130. on mouseUp
  131.     repeat with i=1 to the number of fields 
  132.     -- or buttons, cards, background buttons, etc.
  133.     show field i -- or button, card, etc.
  134.     end repeat
  135. end mouseUp
  136.  
  137. Animating Cursors
  138. Would you like a “cute” animated cursor during certain HyperCard operations? Create the various versions of the cursor. Number these versions consecutively. Now the script — repeatedly call for those numbers, like this:
  139. on MyCursor
  140.     repeat with CNum = 128 to 134
  141.     -- or whatever numbers you used
  142.         set cursor to CNum
  143.     end repeat
  144. end MyCursor
  145.  
  146. Lose Those Curly Quotes 
  147. If you use Laser Quotes or some other INIT or cdev to make " and ' into “ or ” and ‘ or ’ none of your HyperCard scripts containing quotation marks will work. Disable the curly quotes while typing scripts in HyperCard.
  148.  
  149. The Pointy Finger
  150. When you ask HyperCard for “the mouseLoc” you get the location of the middle pixel on the end of the pointing finger of the browse tool.
  151.  
  152. NASA and the Mac
  153. NASA is now using a HyperCard stack to find images on a DEC MicroVax file server. The images are displayed on a networked Mac II.
  154.  
  155. Upper or Lower — Doesn’t Matter
  156. Nothing is case sensitive in HyperCard. So all these will work: GO next card, go Next Card, GO NEXT CARD, go next card, or go NeXt CaRd.
  157.  
  158. New Commands
  159. Some of the new commands available in HyperCard 1.2 include find whole, find string, hide/show card/background/picture, select before/after text, chunk of field/msg box/field, the click v, the click H, the found chunk, the found field, the found line and many others.
  160. Here is a script which is making the rounds for entering FatBits easily:
  161.  
  162. on mouseUp 
  163.     -- Zoom Z, C. Davis, 1988 after G. Porter 1988
  164.     wait until the mouse is down
  165.     choose pencil tool
  166.     click at the mouseLoc with CommandKey
  167.     wait until the mouse is up
  168.     choose browse tool
  169. end mouseUp
  170.  
  171. If you try it, you will find that once in FatBits, you can’t stay to do any work. Cut the lines above mouseUp which say “wait until the mouse is up” and “choose browse tool” and it works fine. Does anyone know what those extra two lines are supposed to do?
  172.  
  173. Good Vaporware!
  174. Is vaporware good or bad? Maybe good in this case. There is a HyperCard stack called ΔH(vapor) which studies the vapor pressure of liquids as a function of temperature.
  175.  
  176. Losing Visual Effects on a II
  177. I lost all my visual effects in HyperCard. Where did they go? If you have a Mac II and are operating in color mode, that’s why they are gone. Use the 2-bit black and white mode. I thought HyperCard 1.2 was doing it, since I got the Mac II and HyperCard 1.2 at the same time. Not true. It’s the color mode which disables visual effects.
  178.  
  179. Stacking Toggled Buttons
  180. One handy HyperCard trick is to stack two “toggling” buttons on top of each other, so that when one is selected, the other automatically gets top position and is visible. Here’s how. Make two buttons. Name them appropriately (I’m using ButtonOne and ButtonTwo). ButtonOne gets this script:
  181.  
  182. on mouseUp
  183.     hide card button ButtonOne
  184.     show card button ButtonTwo
  185. end mouseUp
  186.  
  187. Script ButtonTwo to hide Two and show One, using the script format above. Put in any other scripting to make the buttons do what you wish. Drag one button on top of the other. Get the browse tool and try it out. To get at the bottom button for any reason, use the message box and type show card button ButtonOne (or ButtonTwo, as needed). Or just get the button tool, select the top button and drag it off to the side, revealing the other button.
  188.  
  189. Cheapie Protection
  190. Here is a simple, low-level device to keep prying eyes out of your stack. Put it in your stack script:
  191.  
  192. on OpenStack
  193.     ask "Password, please?"
  194.     if it is "yourPassword" then 
  195.     -- put your password where it says "yourPassword"
  196.         go to next card -- or whatever you want it to do
  197.     else
  198.         go home -- or quit HyperCard, or whatever you wish
  199.     end if
  200. end OpenStack
  201.  
  202. This will keep the IBM rabble and non-programmer Mac owners out, but it isn't very sophisticated. Any script reading stack will strip your password out for the world to see.
  203.  
  204. Your Own Dialog Boxes
  205. Dialog boxes are easy in HyperCard. Try this example, then replace the words in quotes with your own text. Create a button and script it this way:
  206.  
  207. on mouseUp
  208.     answer "What shall I do?" with "Continue" or "quit" or "punt"
  209.     -- you cannot have more than three answer choices
  210. end mouseUp
  211.  
  212. And here is an "ask" script:
  213.  
  214. on mouseUp
  215.      ask "Type Your Name" with "John Q. Public"
  216.       if it is "Phil Russell" then
  217.        go next card -- or whatever you want done
  218.       else
  219.         if it is not Alfonso Smith then
  220.               go previous card -- or whatever you want done
  221.         end if
  222.     end if
  223. end mouseUp
  224.  
  225. Remember, you can substitute your own "Ask" criteria (Type Your Name), your own default (John Q. Public), your own "correct" response (Phil Russell) and your own desired HyperCard actions depending on what is typed into the dialog box. In fact, can you see how to make this Ask statement into a simple password protection for a stack?
  226.  
  227. Auto-Scripting
  228. Here is a time saver in HyperCard. If you have several lines of script which you would like to use several times without retyping it? To do this,  you will create a subroutine in HyperCard, and then call for the subroutine to automatically type the script for you. Here is an example:
  229.  
  230. on myCommand --your subroutine, in this case named
  231. -- MyCommand, must be without spaces
  232. -- place the script which you want to use repeatedly right here
  233. end myCommand
  234.  
  235. Now you can imbed this routine in any script. To do that, when you are ready for the script you hid in myCommand, you simply type myCommand, and the script is executed. 
  236.  
  237.